home *** CD-ROM | disk | FTP | other *** search
/ Trusted Irix /B 4.0.4 / Trusted-Irix B-4.0.1.iso / dist / eoe1.idb / usr / include / sys / gfx.h.z / gfx.h
C/C++ Source or Header  |  1992-04-03  |  10KB  |  326 lines

  1. #ifndef __SYS_GFX_H__
  2. #define __SYS_GFX_H__
  3.  
  4. /**************************************************************************
  5.  *         Copyright (C) 1990, Silicon Graphics, Inc.          *
  6.  *  These coded instructions, statements, and computer programs     contain  *
  7.  *  unpublished     proprietary  information of Silicon Graphics, Inc., and  *
  8.  *  are protected by Federal copyright law.  They  may    not be disclosed  *
  9.  *  to    third  parties    or copied or duplicated in any form, in whole or  *
  10.  *  in part, without the prior written consent of Silicon Graphics, Inc.  *
  11.  **************************************************************************/
  12.  
  13. /*
  14.  *   $Revision: 1.68 $
  15.  */
  16.  
  17.  
  18. /*
  19.  *   I_STR ioctl commands for gfx STREAMS
  20.  *
  21.  *   All Gfx ioctls share the same cmd token space to
  22.  *   avoid unnecessary indirections.
  23.  *
  24.  *   There are three types of ioctl.
  25.  *     - GFX device independant gfx operations (defined here)
  26.  *     - RRM rendering resource manager commands (defined in rrm.h)
  27.  *     - Graphics board specific cmds (defined in a board-specific header e.g. gr1.h)
  28.  */
  29.  
  30. #ifndef NULL
  31. #define    NULL    0
  32. #endif
  33. /*
  34.  *   GFX commands
  35.  */
  36.  
  37. #define GFX_SYNC                (1)
  38. #define GFX_BOARD_SYNC          (10)
  39.  
  40. #define GFX_BASE        100
  41. #define GFX_GETNUM_BOARDS    (GFX_BASE+1)
  42. #define GFX_GETBOARDINFO    (GFX_BASE+2)
  43. #define GFX_ATTACH_BOARD    (GFX_BASE+3)
  44. #define GFX_DETACH_BOARD    (GFX_BASE+4)
  45. #define GFX_IS_MANAGED        (GFX_BASE+5)
  46.  
  47.     /* Have to be the board owner to use these */
  48. #define GFX_INITIALIZE        (GFX_BASE+6)
  49. #define GFX_START        (GFX_BASE+7)
  50. #define GFX_DOWNLOAD        (GFX_BASE+8)
  51. #define GFX_BLANKSCREEN        (GFX_BASE+9)
  52. #define GFX_MAPALL        (GFX_BASE+10)
  53. #define GFX_LABEL        (GFX_BASE+11)
  54. #define GFX_REATTACH_BOARD    (GFX_BASE+12)
  55. #define GFX_SET_DIAG_FLAG    (GFX_BASE+13)
  56.  
  57.     /* XXX for debugging, remove later */
  58. #define GFX_DEBUGMAP        (GFX_BASE+100)
  59. #define GFX_DUMMY        (GFX_BASE+101)
  60.  
  61.         /* Start of board private commands */
  62. #define GFX_PRIVATE_BASE        10000
  63.  
  64. /*
  65.  *    gfx ioctl arguments
  66.  */
  67.  
  68. struct gfx_getboardinfo_args {
  69.     unsigned long int board; /* board number (contiguous from zero) */
  70.     void *buf;        /* buffer for reply */
  71.     unsigned long len;    /* max length, length of reply (bytes) */
  72. };
  73.  
  74.  
  75. struct gfx_attach_board_args {
  76.     unsigned long int board;
  77.     unsigned long int vaddr;
  78. };
  79.  
  80. struct gfx_download_args {        /* GFX_DOWNLOAD */
  81.     long int len;            /* length in bytes of ucode buffer */
  82.     void *addr;            /* address of ucode buffer */
  83.     long magic;            /* magic number in ucode file */
  84.     long unit;            /* unit number to load ucode into */
  85.     long off;            /* offset in memory space where ucode goes */
  86.     long width;            /* width in bytes of ucode word */
  87.     long entry;            /* entry point (if applicable) */
  88.     long run;            /* run flag (should the engine be started?) */        
  89. };
  90.  
  91. #define GFX_DOWNLOAD_LIMIT 4096
  92.  
  93. struct gfx_private_args {
  94.     unsigned long int cmd;
  95.     char data[1];
  96. };
  97.  
  98. /*
  99.  *   M_PROTO message types for gfx STREAM
  100.  */
  101. #define GFX_PROTO_ACK        1
  102. #define GFX_PROTO_NACK        -1
  103. #define GFX_PROTO_BASE        100
  104. #define GFX_POSCURSOR        (GFX_PROTO_BASE+2)
  105.  
  106. /*
  107.  *   PROTO message args
  108.  */
  109.  
  110. struct gfx_poscursor {
  111.     long int cmd;            /* GFX_POSCURSOR */
  112.     long int x ;
  113.     long int y ;
  114. };
  115.  
  116. union gfx_proto    {
  117.     long int cmd;            /* may be unknown */
  118.     struct gfx_poscursor poscursor;
  119. };
  120.  
  121.  
  122. /*
  123.  *   Graphics board description
  124.  */
  125.  
  126. #define GFX_INFO_NAME_SIZE     16
  127. #define GFX_INFO_LABEL_SIZE     16
  128.  
  129. struct gfx_info {
  130.     char name[GFX_INFO_NAME_SIZE];     /* unique name for this graphics */
  131.     char label[GFX_INFO_LABEL_SIZE];/* manager's name for this board */
  132.         unsigned short int xpmax;    /* screen x size in pixels */
  133.     unsigned short int ypmax;    /* screen y size in pixels */
  134.     unsigned int length;        /* size of a complete info struct */
  135.                                     /* for this board */
  136. };
  137.  
  138. #define GFX_SYNC_VALUE  3
  139.  
  140. #ifdef _KERNEL
  141.  
  142. /*
  143.  * Device independent interface to device dependent graphics board functions.
  144.  */
  145.  
  146. struct gfx_fncs {
  147.              /* functions for the Graphics Driver */
  148.     int (*gf_Info)(struct gfx_data *, void *, unsigned int);    
  149.     int (*gf_Attach)(struct gfx_gfx *, unsigned long int);
  150.     int (*gf_Detach)(struct gfx_gfx *);
  151.     int (*gf_Initialize)(struct gfx_gfx *);
  152.     int (*gf_Download)(struct gfx_gfx *, struct gfx_download_args *);
  153.     int (*gf_Start)(struct gfx_gfx *);
  154.     int (*gf_PositionCursor)();
  155.     int (*gf_Sync)(unsigned int);
  156.  
  157.             /* functions for the Rendering Resource Manager */
  158.     int (*gf_CreateDDRN)(struct gfx_data *, struct rrm_rnode *);
  159.     int (*gf_DestroyDDRN)(struct gfx_data *, struct gfx_gfx *, struct rrm_rnode *);
  160.     int (*gf_ValidateClip)(struct gfx_gfx *, struct rrm_rnode *,
  161.         struct rrm_rnode *, struct RRM_ValidateClip *);
  162.     int (*gf_MapGfx)(struct gfx_gfx *, long, long);
  163.     int (*gf_UnMapGfx)(struct gfx_gfx *);
  164.     int (*gf_InvalTLB)(struct gfx_gfx *);
  165.     int (*gf_PcxSwap)(struct gfx_data *, struct rrm_rnode *,
  166.         struct rrm_rnode *, struct rrm_rnode *);
  167.     int (*gf_PcxSwitch)(struct gfx_data *, struct rrm_rnode *,
  168.         struct rrm_rnode *);
  169.     int (*gf_SchedSwapBuf)(struct gfx_data *, struct rrm_rnode *,long,long);
  170.     int (*gf_UnSchedSwapBuf)(struct gfx_gfx *, struct rrm_rnode *, long);
  171.     int (*gf_SchedRetraceEvent)(struct gfx_data *, struct rrm_rnode *);
  172.     int (*gf_SetDisplayMode)(struct gfx_gfx *, long, unsigned long);
  173.     int (*gf_Suspend)(struct gfx_data*, struct gfx_gfx *);
  174.     int (*gf_Resume)(struct gfx_data*, struct gfx_gfx *);
  175.  
  176.     /*
  177.      * routine to call graphics board driver specific functions.
  178.      */
  179.     int (*gf_Private)(struct gfx_gfx*, struct rrm_rnode *,
  180.         unsigned long, void *);
  181.  
  182.     /*
  183.      * provide a pointer to appropriate spl?() routines for
  184.      * the given hardware.
  185.      */
  186.     int    (*gf_SplRetrace)();
  187. };
  188.  
  189.  
  190. static struct gfx_board { 
  191.     struct gfx_info *gb_info ;
  192.     struct gfx_gfx *gb_manager;
  193.     struct gfx_gfx *gb_owner;
  194.     int gb_number;       /* same as index in GfxBoards */
  195.     struct queue *gb_rq_ptr;
  196.     struct queue *gb_wq_ptr;
  197.     /* gunk for talking to shimq  */
  198.     short int gb_devminor ;        /* Identifies the shmiq */
  199.     short int gb_index ;        /* Identifies the device */
  200.     struct gfx_fncs *gb_fncs ;
  201.     struct gfx_data *gb_data ;
  202. } ;
  203.  
  204. /*
  205.  *   gfx driver structure
  206.  *   one of these per open board, per process
  207.  */
  208.  
  209. struct gfx_gfx {
  210.  
  211.     /*  generic stuff  */
  212.     struct gfx_board *gx_board; /* pointer to board */
  213.  
  214.     struct proc *gx_pp; /* proc pointer */
  215.     struct gfx_gfx *gx_next;    /* ptr to next open gfx */
  216.  
  217.     /*  board driver stuff    */
  218.     struct gfx_fncs *gx_fncs;
  219.     struct gfx_data *gx_bdata;    /* ptr to driver private data */
  220.                     /* there are many of these pointers */
  221.                     /* but only one copy of the data */
  222.     struct pregion *gx_preg;
  223.     unsigned long int gx_flags;    /* flags needed by char side only */
  224.     unsigned long int gx_sflags;    /* flags needed by both sides */
  225.     unsigned long int gx_tlbmask;    /* for late TLB flushing on (MP) */
  226.  
  227.     /*  rrm stuff  */
  228.     void *gx_openrns;        /* RN's this gfx has open */
  229.     void *gx_boundrn;        /* RN this gfx is currently bound to */
  230.  
  231.     /* share group fields */
  232.  
  233.     sema_t gx_sema;            /* semaphore for multiple sg procs */
  234. };
  235.  
  236.  
  237. /*
  238.  *   Values for gfx_gfx.gx_flags
  239.  */
  240. #define GFX_MAPPED    0x00000001
  241. #define GFX_DIAGMAPALL    0x00000002    /* The pipe is mapped in a special way for diagnostic use */
  242. #define GFX_DIAG_FLAG    0x00000004    /* the process has identified itself as a diagnostic */
  243.  
  244. /*
  245.  *   Values for gfx_gfx.gx_sflags
  246.  */
  247. #define GFXS_STREAM    0x00000001    /* referenced by streams side of driver */
  248. #define GFXS_CHAR    0x00000002    /* referenced by character side of driver */
  249.  
  250. struct gfx_data {
  251.         /* for the Rendering Resource Manager */
  252.     void *currentrn;        /* Current rendering node */
  253.     long int numrns;        /* number of RN's open on this board */
  254.     long int numpcx;        /* number of pipe contexts in hardware*/
  255.     struct rrm_rnode **loadedpcxs;    /* table of pipe contexts loaded
  256.                        in hardware */
  257.     struct rrm_rnode *newestrn;    /* most recently used rnp
  258.                        (pcxid allocation) */
  259.     struct rrm_rnode *oldestrn;    /* least recently used rnp
  260.                        (pcxid allocation) */
  261.     lock_t lock;            /* per board locking mechanism */
  262.     sema_t        gfxsema;    /* The gfx semaphore is held during all
  263.                        times the process has the pipe
  264.                        mapped.  It is also necessary to
  265.                        hold it during modification of
  266.                        rnp->validmask, even if the process
  267.                        doesn't have the pipe.  Unless the
  268.                        gfxlock is non-zero, the process will
  269.                        give up gfxsema during times when it
  270.                        is _not_ running (see rrmSuspend()
  271.                        and rrmResume()).
  272.                      */
  273.     struct gfx_gfx    *gfxsema_owner; /* When the semaphore is grabbed, this
  274.                        is set to the current gfxp.  It is
  275.                        used to avoid re-grabbing gfxsema.
  276.                      */
  277.     int        gfxlock;    /* The lock is used so that even when a
  278.                        process sleeps it will hold gfxsema.
  279.                        This is necessary in ValidateMyPcx,
  280.                        and in some machine dependent code.
  281.                      */
  282.     int        gfxbusylock;    /* when a process switches out, if the
  283.                        device dependent graphics driver decides
  284.                        that its not an opportune time to context
  285.                        switch the graphics (based on user activity)
  286.                        then we can force the state of gfxlock to
  287.                        hold off a graphics context switch.
  288.                     */
  289.     long int nummodes;        /* number of mode registers in
  290.                        hardware*/
  291.     unsigned long *loadedmodes;    /* table of mode registers loaded
  292.                        in hardware */
  293.     volatile int gfxbackedup;    /* flag set by fifo interrupt handler when
  294.                      * fifo is near full and we shouldn't drop 
  295.                      * anymore tokens 
  296.                      */
  297. };
  298.  
  299.  
  300.  
  301.  
  302. /*
  303.  *   args to GfxKiller() routine called by procscan()
  304.  */
  305.  
  306. struct GfxKiller_args {        /* arg struct given to procscan() */
  307.     long int    signal;    /* signal to send */
  308.     struct gfx_data    *bdata;    /* pointer to board data; identifies a board */
  309.     struct proc    *pp;    /* your proc pointer if you shouldn't be killed
  310.                    (e.g. board manager exits), NULL otherwise */
  311. };
  312.  
  313.  
  314. /*
  315.  * Multiple reader, single writer lock routines for list rooted at pp->p_gfx.
  316.  */
  317. extern int  GfxKiller(struct proc *, struct GfxKiller_args *, int);
  318. extern int  GfxListWriterLock(struct shaddr_s *);
  319. extern void GfxListWriterUnlock(struct shaddr_s *, int);
  320. extern void GfxListReaderLock(struct shaddr_s *);
  321. extern void GfxListReaderUnlock(struct shaddr_s *);
  322.  
  323. #endif /* _KERNEL */
  324.  
  325. #endif /* __SYS_GFX_H__ */
  326.